Quote: npc_drone.team = 0
npc_drone.health = 2000(900_ARMOR+1100_SHIED)
npc_droner.attackdelay = 200
npc_drone.attackdist = 250
npc_droner.movementdelay = 1000
npc_drone.movementspeed = 32
npc_drone.movementmax = 100
npc_drone.sprite = "gfx/models/npcs/drone/drone_heavy_textur/drone_Heavy.bmp"
npc_drone.spritemode = 3
npc_drone.hitzonemode = 101
npc_drone.viewdist = 500
function npc_drone:init()
self.var.turretsprite = image("gfx/models/building/big_realgun_turrel/realgun_B.bmp", 0, 0, 3)
self.var.last_hit = 0
self.var.hit_sound_id = 0
self.var.hit_sound = {}
self.var.hit_sound[1] = {dir = "sfx/fire/big_turrel_shoot/big_realgun_turrel_shoot1.ogg",duration = 1498}
self.var.hit_sound[2] = {dir = "sfx/fire/big_turrel_shoot/big_realgun_turrel_shoot2.ogg",duration = 663}
self.var.hit_sound[3] = {dir = "sfx/fire/big_turrel_shoot/big_realgun_turrel_shoot3.ogg",duration = 925}
self.var.hit_sound[4] = {dir = "sfx/fire/weapon/medium_weapon/swarm_launceh_shoot.ogg",duration = 1117}
self.var.shotcnt = 0
self.var.shotdelay = 0
self.var.aimrottarget = self:rot()
self.var.aimlast = 0
imagepos(self.var.turretsprite, self:x(), self:y(), self:rot())
end
function npc_drone:tweenUpdateSprite(t,x,y)
local _r = self.var.lastrot or 0
tween_move(self.var.turretsprite, t, x, y)
end
function npc_droner:aim(x,y)
local rot = math.deg(self:angle(x,y))
if self.var.aimrottarget ~= rot and Millisecs() - self.var.aimlast >= self.attackdelay then
self.var.aimlast = Millisecs()
self.var.aimrottarget = rot
tween_rotate(self.var.turretsprite, self.attackdelay, rot)
end
end
function npc_drone:onDie()
self:sound3("sfx/npc/ drone / drone _die.ogg", 400)
if self.var.turretsprite and object(self.var.turretsprite, "exists") then
freeimage(self.var.turretsprite)
end
self:freeslot()
if self.block_img and object(self.block_img, "exists") then
freeimage(self.block_img)
self.block_img = nil
end
end
function npc_drone:onHit(attacker,wpn,dmg,isNPC)
self.health = self.health - dmg
if self.health <= 0 then
self:onDie()
elseif not self.var.hit_sound[self.var.hit_sound_id] or Millisecs() >= self.var.last_hit + self.var.hit_sound[self.var.hit_sound_id].duration then
self.var.last_hit = Millisecs()
self.var.hit_sound_id = self.var.hit_sound_id + math.random(1, 4)
if self.var.hit_sound_id > #self.var.hit_sound then
self.var.hit_sound_id = self.var.hit_sound_id - #self.var.hit_sound
end
self:sound3(self.var.hit_sound[self.var.hit_sound_id].dir, 380)
end
end
function npc_ drone:onMove(x,y,r)
self:sound3("sfxz/npc/ drone / drone _step"..math.random(1,6)..".ogg", 400)
if self.lastTarget == 0 then self:aim(x, y) end
if not self.var.lastrot then
self.var.lastrot = 15
else
self.var.lastrot = -self.var.lastrot
end
return 0, r + self.var.lastrot
end
function npc_drone:Always()
if self.fire_executed then
if Millisecs() - self.fire_start >= 1229 then
if self.block_img and object(self.block_img, "exists") then
freeimage(self.block_img)
self.block_img = nil
end
local targets = self:ClosestTargets(self.fire_id, 96, self.fire_npc)
parse("flashposition "..self.fire_x.." "..self.fire_y.." 50")
self.fire_executed = false
for _, t in pairs(targets) do
local _id = t[1]
local _isNPC = t[2]
if _isNPC and _id ~= self.id then
NPC_Tab[_id]:onHit(_id, 0, 1000, true)
end
end
parse("explosion "..self.fire_x.." "..self.fire_y.." 128 1000")
end
end
end
function npc_drone:onAttack(id,isNPC)
if Millisecs() - self.var.shotdelay >= 2000 then
if self.targetAttackable then
local targets = self:ClosestTargets(id, 64, isNPC)
if #targets >= 3 then
if not self.fire_executed then
self:sound3("sfx/npc/ drone /fail_drone_heavy.ogg", 380)
self.last_attack = Millisecs() + 3000
self.last_move = Millisecs() + 1229
self.fire_executed = true
self.fire_start = Millisecs()
self.fire_npc = isNPC
self.fire_id = id
self.fire_x = self.targetx
self.fire_y = self.targety
self.block_img = image("gfx/sprites/block.bmp", 0, 0, 1)
imagescale(self.block_img, 1/32, self:dist(self.targetx, self.targety)/32)
imagepos(self.block_img, (self.targetx + self:x())/2, (self.targety + self:y())/2, math.deg(self:angle(self.targetx, self.targety)))
end
else
if isNPC then
NPC_Tab[id]:onHit(self.id, 0, math.random(10,14) , true)
else
local h, a = CalcDamage(player(id,"health"), player(id,"armor"), math.random(8,12))
if h > 0 then
parse("sethealth "..id.." "..h)
parse("setarmor "..id.." "..a)
else
parse('customkill 0 "Drone" '..id)
end
end
local img = image("gfx/models/npcs/ drone / drone _shot.bmp", 0, 0, 1)
imagepos(img, self:x(), self:y(), object(self.var.turretsprite, "rot") or self:rot())
tween_alpha(img, 200, 0)
timer(500, "freeimage", img)
self:sound3("sfx/npc/ drone /minmatar _minigun"..math.random(1,2)..".ogg", 380)
self.var.shotcnt = self.var.shotcnt + 1
if self.var.shotcnt >= 10 then
self.var.shotdelay = Millisecs()
self.var.shotcnt = 0
end
end
end
end
end